package string;

import java.util.Scanner;

public class StartsWithDemo {
    public static void main(String[] args) {
        String str = "hello world";
        //判断字符串是不是以“he“开头
        System.out.println(str.startsWith("he"));//boolean类型输出true或者false
        //判断字符串是不是以”ld“结尾
        System.out.println(str.endsWith("world"));
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入字符串：");
            String s =scanner.nextLine();//输入字符串
            if (s.equals(str)) {
                System.out.println("you are right!");
                break;
            }
        }
    }
}
